load("@rules_foreign_cc//foreign_cc:defs.bzl", "configure_make")
load("@rules_license//rules:license.bzl", "license")

package(default_applicable_licenses = [":license"])

license(
    name = "license",
    license_kinds = ["@rules_license//licenses/spdx:MIT"],
    license_text = "LICENSE",
    visibility = ["//visibility:public"],
)

exports_files(["LICENSE"])

filegroup(
    name = "all_srcs",
    srcs = glob(["**"]),
)

configure_make(
    name = "libffi",
    configure_options = ["--disable-multi-os-directory"],
    copts = ["-fPIC"],
    # https://github.com/bazel-contrib/rules_foreign_cc/issues/338.
    env = {"AR": ""},
    lib_name = "libffi",
    lib_source = ":all_srcs",
    visibility = ["//visibility:public"],
)
